/* eslint-disable no-unused-vars */
import namespace from "../../namespace";
// import ArrayList from "../../util/ArrayList";

class VertexSelectionPolicy extends namespace.policy.figure.SelectionPolicy {
  constructor() {
    super();
  }

  /**
   * @inherit
   * @param {} canvas
   * @param {*} figure
   */
  onSelect(canvas, figure) {
    const points = figure.getVertices();
    points.each((i, p) => {
      let handle = this.createVertexResizeHandle(figure, i);
      figure.selectionHandles.add(handle);
      handle.show(canvas);
    });

    this.move(canvas, figure);
  }

  /**
   * 移动各个顶点小矩形
   * @inherit
   * @param {} canvas
   * @param {*} figure
   */
  move(canvas, figure) {
    figure.selectionHandles.each((i, e) => e.updateLocation());
  }

  createVertexResizeHandle(owner, index) {
    return new namespace.VertexResizeHandle(owner, index);
  }
}

namespace.policy.figure.VertexSelectionPolicy = VertexSelectionPolicy;
